#include "graph.h"
#include <bits/stdc++.h>
using namespace std;
const int N=205;
int sign,t,to[N][N],e[N][N],ans[N];
bool tr[N][N],fa[N][N];
void dfs1()
{
	int x=++sign,deg=NumberOfRoads(),lst=LastRoad();
	for(int i=1;i<=deg;i++) if(i!=lst)
	{
		Move(i,2);
		if(Color()==2) fa[x][i]=1,Move(LastRoad(),2);
		else if(Color()==1) tr[x][i]=1,to[x][i]=sign+1,dfs1();
		else Move(LastRoad(),3);
	}
	if(x!=1) Move(lst,3);
}
void dfs2()
{
	int x=++sign;
	int deg=NumberOfRoads(),lst=LastRoad(),c=sign;
	for(int i=1;i<=t;i++) c/=3;
	c=c%3+1;
	for(int i=1;i<=deg;i++) if(tr[x][i]||fa[x][i])
	{
		Move(i,c);
		if(tr[x][i]) dfs2();
		else
		{
			to[x][i]=to[x][i]*3+Color()-1;
			Move(LastRoad(),Color());
		}
	}
	if(x!=1) Move(lst,c);
}
void Inspect(int R)
{
	dfs1(); int n=sign;
	for(t=4;t>=0;t--) sign=0,dfs2();
	memset(e,0x3f,sizeof(e));
	for(int i=1;i<=n;i++)
	{
		e[i][i]=0;
		for(int j=1;j<=n;j++)
			if(to[i][j]) e[i][to[i][j]]=e[to[i][j]][i]=1;
	}
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++) e[i][j]=min(e[i][j],e[i][k]+e[k][j]);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++) if(e[i][j]<=R) ans[e[i][j]]++;
	for(int i=1;i<=R;i++) Answer(i,ans[i]);
}
